<TreeView x:Class="ICSharpCode.Data.Core.UI.UserControls.DatabasesTreeView"
    x:Name="This"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:data="http://icsharpcode.net/data"
    xmlns:local="clr-namespace:ICSharpCode.Data.Core.UI.UserControls">
    <TreeView.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="DatabaseTreeViewResources.xaml" />
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </TreeView.Resources>
    
    <TreeViewItem x:Name="tviDatabases" ItemsSource="{Binding Databases, ElementName=This}" ItemTemplateSelector="{StaticResource DatabaseTreeViewDataTemplateSelector}">
        <TreeViewItem.Header>
            <Grid>
                <Grid.ContextMenu>
                    <ContextMenu>
                        <MenuItem Header="Add database..." Click="mnuAddDatabase_Click" />
                        <MenuItem Header="Refresh" Click="mnuRefresh_Click" />
                    </ContextMenu>
                </Grid.ContextMenu>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition />
                </Grid.ColumnDefinitions>
                
                <Image Margin="2" Source="{StaticResource DatabaseImage}" Width="16" Height="16" />
                <TextBlock Margin="2" Grid.Column="1" Text="Databases" VerticalAlignment="Center" />
            </Grid>
        </TreeViewItem.Header>
    </TreeViewItem>
</TreeView>